package com.jzo2o.customer.controller.agency;


import com.jzo2o.common.model.Result;
import com.jzo2o.customer.model.dto.request.InstitutionCertificationAuditAddReqDTO;
import com.jzo2o.customer.model.dto.request.InstitutionRegistrReqDTO;
import com.jzo2o.customer.model.dto.response.NewRejectReason;
import com.jzo2o.customer.model.dto.response.ServeProviderInfoResDTO;
import com.jzo2o.customer.service.IAgencyCertificationService;
import com.jzo2o.customer.service.ILoginService;
import com.jzo2o.customer.service.IServeProviderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 服务人员/机构表 前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-07-17
 */
@RestController("agencyServeProviderController")
@RequestMapping("/agency")
@Api(tags = "机构端 - 服务人员或机构相关接口")
public class ServeProviderController {
    @Resource
    private IServeProviderService serveProviderService;
    @Resource
    private ILoginService loginService;
    @Resource
    private IAgencyCertificationService agencyCertificationService;


    @GetMapping("/serve-provider/currentUserInfo")
    @ApiOperation("获取当前用户信息")
    public ServeProviderInfoResDTO currentUserInfo() {
        return serveProviderService.currentUserInfo();
    }

    @PostMapping("/serve-provider/institution/resetPassword")
    @ApiOperation("机构人员重置密码")
    public Result InstitutionResetPassword(@RequestBody InstitutionRegistrReqDTO institutionRegistrReqDTO) {
        loginService.InstitutionResetPassword(institutionRegistrReqDTO);
        return Result.ok();
    }
    @PostMapping("/agency-certification-audit")
    @ApiOperation("机构端提交认证")
    public Result InstitutionAuditCertification(@RequestBody InstitutionCertificationAuditAddReqDTO institutionRegistrReqDTO) {
        agencyCertificationService.add(institutionRegistrReqDTO);
        return Result.ok();
    }
    @GetMapping("/agency-certification-audit/rejectReason")
    @ApiOperation("机构端最新驳回原因")
    public NewRejectReason InstitutionNewRejectReason () {
       String newRejectReaso = agencyCertificationService.queryNewRejectReason();
        NewRejectReason newRejectReason = new NewRejectReason();
        newRejectReason.setRejectReason(newRejectReaso);
        return newRejectReason;
    }

}
